package com.bs.mapper;

import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import com.bs.utils.*;
import com.bs.bean.Admin;

/*持久层接口，封装了对admin表的增删改查方法功能*/
public interface AdminMapper {

//	定义表名
	public static final String table="admin";

//  查询admin表中的所有数据
	@Select("select * from "+DBUtils.perfix+table+DBUtils.sufix+"")
	List<Admin> selectByExample(Admin admin);
	
//  根据主键username查询admin表中对应的数据
	@Select("select * from "+DBUtils.perfix+table+DBUtils.sufix+" where "+DBUtils.perfix+"username"+DBUtils.sufix+"=#{username}")
	Admin selectByPrimaryKey(String username);
	
//  向admin表中的添加一条数据
	@Insert("insert into "+DBUtils.perfix+table+DBUtils.sufix+" values(#{username},#{password})")
	int insertSelective(Admin admin);

//  根据主键username更新admin表中对应的数据
	@Update("update "+DBUtils.perfix+table+DBUtils.sufix+" set "+DBUtils.perfix+"username"+DBUtils.sufix+"=#{username},"+DBUtils.perfix+"password"+DBUtils.sufix+"=#{password} where "+DBUtils.perfix+"username"+DBUtils.sufix+"=#{username}")
	int updateByPrimaryKey(Admin admin);
	
//  根据主键username删除admin表中对应的数据
	@Delete("delete from "+DBUtils.perfix+table+DBUtils.sufix+" where "+DBUtils.perfix+"username"+DBUtils.sufix+"=#{username}")
	int deleteByPrimaryKey(String username);
}